﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<qlqa.Models.Form.ThucDonForm.ThucDonForm>" %>
<%@ Import Namespace="qlqa.Delegate.CommonDelegate" %>
<%@ Import Namespace="qlqa.Models.LinQ" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<% var commonDelegate = new CommonDelegate(); %>
<script type="text/javascript">
    $('#myPager a').click(function () {
        if (this.href != "") {
            $.ajax({
                url: this.href,
                type: 'GET',
                cache: false,
                beforeSend: function () {
                },
                success: function (result) {
                    $('#divDanhSachThucDon').html(result);
                },
                complete: function () {

                }
            });
            return false;
        }
        return false;
    });
</script>
<input type="hidden" id="PageNumber" value="<%:Model.PageNumber %>"/>
<table id="tblThucDon" class="table table-bordered" style="cursor: pointer">
    <thead>
        <tr>
            <th class="text-center">
                #
            </th>
            <th style="display: none">
                RoleId
            </th>
            <th class="text-center">
                Tên thực đơn
            </th>
            <th class="text-center">
                Trạng thái
            </th>
            <th class="text-center">
                Cập nhật
            </th>
            <th class="text-center">
                Xóa
            </th>
        </tr>
    </thead>
    <tbody>
        <% var stt = Model.PageNumber == 0 ? 1 : (Model.PageNumber - 1)*10 + 1; 
            foreach (tb_ThucDon thucDon in Model.DanhSachthucDon)
           { %>
            <tr onclick="toMauRow.call(this,event)">
                <td class="text-center"> <%: stt %> </td>
                <td style="display: none"> <%: thucDon.Id %> </td>
                <td> <%: thucDon.Ten %> </td>
                <td class="text-center"> <%: thucDon.IsSuDung == true ? "Sử dụng" : "Không dùng" %> </td>
                <td class="text-center">
                    <span onclick="getInfoThucDon(<%: thucDon.Id %>)" class="glyphicons glyphicons-pencil">
                    </span>
                </td>
                <td class="text-center">   <span onclick="XoaThucDon(<%: thucDon.Id %>)" class="fa fa-trash-o"></span></td>
            </tr>
        <% stt++;
           } %>
    </tbody>
    <tfoot>
        <tr>
            <td>
            </td>
            <td colspan="4">
                <%
                    var pagerOptions = new PagerOptions();
                    commonDelegate.ChangeTextPaging(pagerOptions, "PageNumber");
                %>
                <div id="myPager">
                    <%= Html.Pager(Model.DanhSachthucDon, pagerOptions) %></div>
                <%= Html.Hidden("PageNumber", Model.PageNumber) %>
            </td>
        </tr>
    </tfoot>
</table>